package ru.ksu.ktk.diploma.sdi.bean;

import ru.ksu.ktk.diploma.sdi.model.DataProperty;
import ru.ksu.ktk.diploma.sdi.model.CRMClass;

import javax.faces.context.FacesContext;
import javax.faces.context.ExternalContext;
import java.util.*;

/**
 * Created by IntelliJ IDEA.
 * User: coldflame
 * Date: 21.12.2008
 * Time: 17:30:03
 * To change this template use File | Settings | File Templates.
 */
public class MappingBean {
    private List<DataProperty> properties = new ArrayList<DataProperty>();
    private List<CRMClass> crmClasses = new ArrayList<CRMClass>();

    public List<DataProperty> getProperties() {
        properties.add(new DataProperty("name"));
        properties.add(new DataProperty("field_1081610380"));
        properties.add(new DataProperty("field_2082124554"));
        return properties;
    }

    public void setProperties(List<DataProperty> properties) {
        this.properties = properties;
    }

    public List<CRMClass> getCrmClasses() {
        Random random = new Random();
        int count = random.nextInt(1) + 1;
        for (int i = 0; i < count; i++) {
            int number = random.nextInt(60) + 1;
            crmClasses.add(new CRMClass("E" + number));
        }
        return crmClasses;
    }

    public void setCrmClasses(List<CRMClass> crmClasses) {
        this.crmClasses = crmClasses;
    }
    public String retrieveStatemens() {
        return "retrieveStatements";
    }
    public String getProcessedFile() {
        ExternalContext context = FacesContext.getCurrentInstance().getExternalContext();
        Map<String, String> parameterMap = context.getRequestParameterMap();
        String fileName = parameterMap.get("processedFile");
        return fileName;
    }
}
